package com.wxl.micro.service.wms.controller;

import org.springframework.web.bind.annotation.*;

import java.util.concurrent.TimeUnit;

@RestController
@RequestMapping("/wms")
public class WmsController {

    @GetMapping("/delivery")
    public String delivery(@RequestParam String orderId){
        System.out.println("订单发货了。orderId:"+orderId);
        return "订单发货了。orderId:"+orderId;
    }


    @GetMapping("/query")
    public String query(){
        System.out.println("/wms/query");
        return "/wms/query";
    }

    @GetMapping("/exception")
    public String exception(){
        System.out.println("/wms/exception");
        int a = 1 / 0;
        return "/wms/exception";
    }

    @GetMapping("/timeout")
    public String timeout(){
        System.out.println("/wms/timeout 1秒");
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "/wms/timeout";
    }


    @PostMapping("/post")
    public String post(@PathVariable("id") String id){
        System.out.println("/wms/post/"+id);
        return "/wms/post"+id;
    }


    @GetMapping("/header")
    public String header(@RequestHeader("X-Request-custom") String custom){
        System.out.println("/wms/header:"+custom);
        return "/wms/header:"+custom;
    }

    @GetMapping("/tid")
    public String tid(@RequestHeader("tid") String tid){
        System.out.println("/wms/tid:"+tid);
        return "/wms/tid:"+tid;
    }

}
